home *** CD-ROM | disk | FTP | other *** search
- Path: news.kreonet.re.kr!usenet
- From: jwhahn@cair.kaist.ac.kr (Jung Hahn)
- Newsgroups: comp.lang.c++
- Subject: Re: ???Recursion and strings
- Date: Wed, 07 Feb 1996 11:23:20 GMT
- Organization: Applied Database Labs, K.A.I.S.T
- Message-ID: <31188b9a.12102227@news.kreonet.re.kr>
- References: <4f44fg$74u@upsidedown.MTS.Net>
- NNTP-Posting-Host: swine.kaist.ac.kr
- X-Newsreader: Forte Agent .99d/32.168
-
- On Mon, 05 Feb 1996 07:26:43 GMT, bwilliam@MTS.Net (George) wrote:
-
- >How do I write a recursive function to print a string using only
- >printf and %c to print it out.
- >
- >George at bwilliam@MTS.Net
- >
-
- #include <stdio.h>
-
- foo( char *s, int len)
- {
- static int count=0;
-
- if ( count++ < len) {
- printf( "%c", *s++);
- foo( s, len);
- }
- }
-
- void main( void)
- {
- char *t = "Hello World\n";
-
- foo( t, strlen(t));
- }
- ___________
-
- Name: Jung w. Hahn
- Elm: jwhahn@cair.kaist.ac.kr
- Phone: 042-869-2959
-